package cn.seapon.talker.adapters;

import java.util.ArrayList;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import cn.seapon.talker.R;
import cn.seapon.talker.fragments.TalkerBasedFragment;

import com.viewpagerindicator.IconPagerAdapter;

public class MainFragmentAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
    protected static final int[] ICONS = new int[] {
            R.drawable.perm_group_calendar,
            R.drawable.perm_group_camera,
            R.drawable.perm_group_device_alarms,
            R.drawable.perm_group_location
    };
    private ArrayList<TalkerBasedFragment> fragments ;


    public MainFragmentAdapter(FragmentManager fm,ArrayList<TalkerBasedFragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
      return fragments.get(position).getTitile();
    }

    @Override
    public int getIconResId(int index) {
      return ICONS[index % ICONS.length];
    }


}